package flc.ast.adapter;

import android.graphics.Color;

import androidx.annotation.NonNull;

import com.chad.library.adapter.base.provider.BaseItemProvider;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.hpplay.sdk.source.browse.api.LelinkServiceInfo;

import flc.ast.R;
import stark.common.basic.adaptermutil.StkProviderMultiAdapter;
import stark.common.basic.adaptermutil.StkSingleSpanProvider;

public class DeviceAdapter extends StkProviderMultiAdapter<LelinkServiceInfo> {

    public DeviceAdapter() {
        addItemProvider(new StkSingleSpanProvider(38));
        addItemProvider(new DeviceProvider());
    }

    private class DeviceProvider extends BaseItemProvider<LelinkServiceInfo> {
        @Override
        public int getItemViewType() {
            return StkProviderMultiAdapter.TYPE_VIEW;
        }

        @Override
        public int getLayoutId() {
            return R.layout.item_device;
        }

        @Override
        public void convert(@NonNull BaseViewHolder baseViewHolder, LelinkServiceInfo info) {
            baseViewHolder.setText(R.id.tvDeviceItemName, info.getName());
            if (info.isConnect()) {
                baseViewHolder.setImageResource(R.id.ivDeviceItemSel, R.drawable.qxlj1);
            } else {
                baseViewHolder.setImageResource(R.id.ivDeviceItemSel, R.drawable.lj1);
            }
        }
    }
}
